<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Main screen</title>
</head>
<body>

	<table border="0" width = "80%" align="center">
		<tr>
			<td>				
				<jsp:include page="header.jsp" />   							
			</td>
		</tr>
		<tr>
			<td>				
				<jsp:include page="search.jsp" />   							
			</td>
		</tr>
		<tr>
			<td>				
				<table border = "0">
					<tr>
					<td width = "30%"  valign = "top">							
							<table border = "0">
								<tr>
									<td></td>
    								<td align = "center"><bean:message key="main.label.mostRecent" /></td>
    								<td><bean:message key="main.label.hits" /></td>
  								</tr>						
								<logic:iterate name="mainForm" property="mostRecentArticles" id="data" indexId="index">
								<tr bgcolor="#fafafa">
									<td>${index+1}</td>
									<td>
										<!-- Title: -->
										<a href="articlePresentationAction.do?articleId=${data.articleId}" >
											<bean:write name="data" property="title" />								
										</a>									
									</td>
									<td>
										<i><bean:write name="data" property="hitCount" /></i>
									</td>								
								</tr>
								</logic:iterate>						
							</table>
						</td>
						<td width = "30%"  valign = "top">							
							<table border = "0">
								<tr>
									<td></td>
    								<td align = "center"><bean:message key="main.label.mostPopular" /></td>
    								<td><bean:message key="main.label.hits" /></td>
  								</tr>						
								<logic:iterate name="mainForm" property="mostPopularArticles" id="data" indexId="index">
								<tr bgcolor="#fafafa">
									<td>${index+1}</td>
									<td>
										<!-- Title: -->
										<a href="articlePresentationAction.do?articleId=${data.articleId}" >
											<bean:write name="data" property="title" />								
										</a>									
									</td>
									<td>
										<i><bean:write name="data" property="hitCount" /></i>
									</td>								
								</tr>
								</logic:iterate>						
							</table>
						</td>
						<td width = "40%" valign = "top">							
							<table border = "0" >
								<tr>
									<td></td>
    								<td align = "center"><bean:message key="main.label.highestRating" /></th>
    								<td><bean:message key="main.label.rate" /></td>
    								<td><bean:message key="main.label.users" /></td>
  								</tr>						
								<logic:iterate name="mainForm" property="articlesWithHighestRating" id="data" indexId = "indx">
								<tr bgcolor="#fafafa">
									<td>${indx+1}</td>
									<td>
										<!-- Title: -->
										<a href="articlePresentationAction.do?articleId=${data.articleId}" >
											<bean:write name="data" property="title" />								
										</a>									
									</td>
									<td>
										<i>
										<c:if test="${data.averageRating == '-1.0'}">NR</c:if>
										<c:if test="${data.averageRating != '-1.0'}">								
											<bean:write name="data" property="averageRating" />																						
										</c:if>										
										</i>
									</td>
									<td>
										<i>
											<bean:write name="data" property="numberOfRatings" />
										</i>
									</td>								
								</tr>
								</logic:iterate>						
							</table>
						</td>						
					</tr>				
				</table>				
			</td>
		</tr>
		<tr>
			<td>				
				<jsp:include page="footer.jsp" />	
			</td>
		</tr>		
	</table>	
</body>
</html>
